package com.un.ebs.core.validator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author liubo
 * @email liubocs@163.com
 * @date 2020/8/12 9:17
 */
public class NotLessThanZeroValidator implements ConstraintValidator<NotLessThanZero, Object> {
    @Override
    public void initialize(NotLessThanZero constraintAnnotation) {

    }

    @Override
    public boolean isValid(Object value, ConstraintValidatorContext constraintValidatorContext) {
        if (null == value) {
            return false;
        }
        if (value instanceof Number) {
            return ((Number) value).doubleValue() > 0 || ((Number) value).doubleValue() < 0;
        }
        return false;
    }
}
